home *** CD-ROM | disk | FTP | other *** search
Text File | 2000-10-06 | 2.9 KB | 112 lines | [TEXT/CWIE] |
- // Play Movie with Controller Sample
- // Based on QTShell
- // WWDC 2000
-
- #include "ComApplication.h"
- #include "ComFramework.h"
- #include "MacFramework.h"
-
- extern Rect gMCResizeBounds; // maximum size for any movie window
-
- //////////
- //
- // CreateController
- // Create and configure the movie controller.
- //
- //////////
-
- MovieController CreateController (Movie theMovie, WindowReference theWindow, Boolean theMoveWindow)
- {
- #if TARGET_OS_WIN32
- #pragma unused(theMoveWindow)
- #endif
-
- MovieController myMC = NULL;
- Rect myRect;
- WindowObject myWindowObject = NULL;
- GrafPtr mySavedPort;
-
- if ((theMovie == NULL) || (theWindow == NULL))
- return(NULL);
-
- // get our window specific data
- myWindowObject = QTFrame_GetWindowObjectFromWindow(theWindow);
- if (myWindowObject == NULL)
- return(NULL);
-
- GetPort(&mySavedPort);
- MacSetPort(QTFrame_GetPortFromWindowReference(theWindow));
-
- // resize the movie bounding rect and offset to 0,0
- GetMovieBox(theMovie, &myRect);
- MacOffsetRect(&myRect, -myRect.left, -myRect.top);
- SetMovieBox(theMovie, &myRect);
- AlignWindow(QTFrame_GetWindowFromWindowReference(theWindow), false, &myRect, NULL);
-
- // create the movie controller
- myMC = NewMovieController(theMovie, &myRect, mcTopLeftMovie);
- if (myMC == NULL)
- return(NULL);
-
- // enable the default movie controller editing
- MCEnableEditing(myMC, true);
-
- // suppress movie badge
- MCDoAction(myMC, mcActionSetUseBadge, (void *)false);
-
- // set the initial looping state of the movie
- QTUtils_SetLoopingStateFromFile(theMovie, myMC);
-
- // install an action filter that does any application-specific movie controller action processing
- MCSetActionFilterWithRefCon(myMC, NewMCActionFilterWithRefConProc(myMCActionFilterProc), (long)myWindowObject);
-
- // add grow box for the movie controller
- if ((**myWindowObject).fCanResizeWindow) {
- #if TARGET_OS_WIN32
- RECT myRect;
-
- GetWindowRect(GetDesktopWindow(), &myRect);
- OffsetRect(&myRect, -myRect.left, -myRect.top);
- QTFrame_ConvertWinToMacRect(&myRect, &gMCResizeBounds);
- #endif
- #if TARGET_OS_MAC
- GetRegionBounds(GetGrayRgn(), &gMCResizeBounds);
- #endif
-
- MCDoAction(myMC, mcActionSetGrowBoxBounds, &gMCResizeBounds);
- }
-
- #if TARGET_OS_MAC
- if (theMoveWindow)
- MoveWindow(theWindow, kDefaultWindowX, kDefaultWindowY, false);
- #endif
-
- MacSetPort(mySavedPort);
-
- // add any application-specific controller functionality
- SetupController(myMC);
-
- return(myMC);
- }
-
- //////////
- //
- // SetupController
- // Configure the movie controller.
- //
- //////////
-
- void SetupController (MovieController theMC)
- {
- long myControllerFlags;
-
- // CLUT table use
- MCDoAction(theMC, mcActionGetFlags, &myControllerFlags);
- MCDoAction(theMC, mcActionSetFlags, (void *)(myControllerFlags | mcFlagsUseWindowPalette));
-
- // enable keyboard event handling
- MCDoAction(theMC, mcActionSetKeysEnabled, (void *)true);
-
- // disable drag support
- MCDoAction(theMC, mcActionSetDragEnabled, (void *)false);
- }